package com.iplant.base.utils.sql.orm;

import com.iplant.base.po.*;
import com.iplant.base.po.base.iPlantRequestBody;

import java.util.List;
import java.util.Map;

/**
 * @author xiuto
 * 继承BasePO的实体类必须使用注解DBBasePO
 */
public interface PoService<T extends BasePO> {

    /**
     * 查询实体类集合
     *
     * @param wLoginUser
     * @param wParams
     * @param wPagination
     * @param wErrorCode
     * @return
     */
    List<T> SelectPOList(
            BaseUser wLoginUser, Map<String, Object> wParams, Pagination wPagination,
            OutResult<Integer> wErrorCode);


    /**
     * 查询实体类集合
     *
     * @param wLoginUser
     * @param wParams
     * @param wPagination
     * @return
     */
    ServiceResult<List<T>> SelectPOList(
            BaseUser wLoginUser,List<Integer> wIDList, Map<String, Object> wParams, Pagination wPagination);


    ServiceResult<List<T>> SelectPOList(BaseUser wLoginUser, Map<String, Object> wParams);

    /**
     * 查询实体类集合
     *
     * @param wLoginUser
     * @param wParams
     * @param wPagination
     * @param wErrorCode
     * @return
     */
    List<T> SelectPOList(
            BaseUser wLoginUser, List<Integer> wIDList, Map<String, Object> wParams, Pagination wPagination,
            OutResult<Integer> wErrorCode);


    List<T> SelectPOList(
            BaseUser wLoginUser, Map<String, Object> wParams, OutResult<Integer> wErrorCode);

    /**
     * 查询实体类集合
     *
     * @param wLoginUser
     * @param wParams
     * @param wPagination
     * @return
     */
    ServiceResult<List<T>> SelectPOList(
            BaseUser wLoginUser, Map<String, Object> wParams, Pagination wPagination);


    /**
     * 查询单条实体类
     *
     * @param wLoginUser
     * @param wParams
     * @param wErrorCode
     * @return
     */
    T SelectPO(
            BaseUser wLoginUser, Map<String, Object> wParams,
            OutResult<Integer> wErrorCode);


    /**
     * 查询单条实体类
     *
     * @param wLoginUser
     * @param wParams
     * @return
     */
    ServiceResult<T> SelectPO(
            BaseUser wLoginUser, Map<String, Object> wParams);



    /**
     * 查询单条实体类
     *
     * @param wLoginUser
     * @param wID
     * @param wCode
     * @return
     */
    ServiceResult<T> SelectPO(
            BaseUser wLoginUser, int wID,String wCode);



    T SelectPO(
            BaseUser wLoginUser, int wID,String wCode,OutResult<Integer> wErrorCode);

    /**
     * 删除实体类
     *
     * @param wLoginUser 用户
     * @param wBasePO    实体类示例
     * @param wErrorCode 错误码
     * @return 删除数据条目数
     */
    int DeletePO(BaseUser wLoginUser, T wBasePO, OutResult<Integer> wErrorCode);


    int DeletePOList(BaseUser wLoginUser, List<T> wBasePOList, OutResult<Integer> wErrorCode);



    int Delete(BaseUser wLoginUser,Map<String, Object> wData, String... wOtherCondition);


    int Delete(BaseUser wLoginUser, String wMustCondition, String... wOtherCondition);





    /**
     * 删除实体类
     *
     * @param wLoginUser
     * @param wBasePO
     * @return
     */
    ServiceResult<Integer> DeletePO(
            BaseUser wLoginUser, T wBasePO);

    ServiceResult<Integer> DeletePO(BaseUser wLoginUser, T wBasePO,Boolean wIsSuper);

    ServiceResult<Integer> DeletePOList(BaseUser wLoginUser, List<T> wBasePOList);

    ServiceResult<Integer> DeletePO(
            BaseUser wLoginUser, Map<String, Object> wParams);


    ServiceResult<Integer> DeletePOList(
            BaseUser wLoginUser, Map<String, Object> wParams);
    ServiceResult<Integer> DeletePOList(BaseUser wLoginUser, List<T> wBasePOList,Boolean wIsSuper);

    /**
     * 修改/新增实体类记录  强制查重
     * @param wLoginUser
     * @param wBasePO
     * @param wErrorCode
     * @return
     */
    int UpdateCheckPo(BaseUser wLoginUser, T wBasePO, OutResult<Integer> wErrorCode);

    /**
     * 修改/新增实体类记录 通过ID或者检查重复的CheckName
     *
     * @param wLoginUser 用户
     * @param wBasePO    实体类示例
     * @param wErrorCode 错误码
     * @return 影响的数据条目数
     */
    int UpdatePo(BaseUser wLoginUser, T wBasePO, OutResult<Integer> wErrorCode);

    /**
     * 修改/新增实体类记录 通过ID或者检查重复的CheckName
     *
     * @param wLoginUser 用户
     * @param wiPlantRequestBody    实体类示例
     * @return 影响的数据条目数
     */
    ServiceResult<T> UpdatePo(BaseUser wLoginUser, iPlantRequestBody<T> wiPlantRequestBody);


    /**
     * 修改/新增实体类记录 通过ID
     * @param wLoginUser
     * @param wBasePO
     * @param wIsCheck  是否强制查重
     * @param wErrorCode
     * @return
     */
    int UpdatePo(BaseUser wLoginUser, T wBasePO,Boolean wIsCheck, OutResult<Integer> wErrorCode);

    /**
     * 修改/新增实体类记录 通过ID
     *
     * @param wLoginUser
     * @param wBasePO
     * @return
     */
    ServiceResult<Integer> UpdatePo(BaseUser wLoginUser, T wBasePO);


    /**
     * 修改/新增实体类记录 通过ID
     *
     * @param wLoginUser
     * @param wBasePO
     * @return
     */
    ServiceResult<Integer> UpdateCheckPo(BaseUser wLoginUser, T wBasePO);


    ServiceResult<T> UpdateSelectPo(BaseUser wLoginUser, T wBasePO);


    List<T> UpdatePoList(BaseUser wLoginUser, List<T> wList ,OutResult<Integer> wErrorCode);

    ServiceResult<T> UpdatePo(BaseUser wLoginUser, Map<String, Object> wParam);

     ServiceResult<T> UpdateSelectPo(BaseUser wLoginUser, Map<String, Object> wParam);

    ServiceResult<List<T>> UpdatePoList(BaseUser wLoginUser,  Map<String,Object> wParam);

    ServiceResult<List<T>> UpdatePoList(BaseUser wLoginUser, iPlantRequestBody<List<T>> wiPlantRequestBody);

    /**
     * 激活实体类数据
     *
     * @param wLoginUser 用户
     * @param wBasePO    实体类示例
     * @param wActive    激活状态
     * @param wErrorCode 错误码
     * @return 影响数据条目数
     */
    int ActivePO(
            BaseUser wLoginUser, T wBasePO, int wActive, OutResult<Integer> wErrorCode);

    int ActivePOList(
            BaseUser wLoginUser, List<T> wBasePOList, int wActive, OutResult<Integer> wErrorCode);

    /**
     * 激活实体类数据
     *
     * @param wLoginUser
     * @param wBasePO
     * @param wActive
     * @return
     */
    ServiceResult<Integer> ActivePO(
            BaseUser wLoginUser, T wBasePO, int wActive);


    ServiceResult<Integer> ActivePOList(BaseUser wLoginUser, List<T> wBasePOList, int wActive);

    ServiceResult<Integer> ActivePOList(
            BaseUser wLoginUser, Map<String, Object> wParam);

    ServiceResult<Integer> ActivePO(
            BaseUser wLoginUser, Map<String, Object> wParam);

    ServiceResult<Integer> ActivePOChange(
            BaseUser wLoginUser, Map<String, Object> wParam);

    int ActivePOChange(
            BaseUser wLoginUser, Map<String, Object> wParams, String wProp, int wActive, int wDeActive, OutResult<Integer> wErrorCode);
}
